package pointers

import (
	"errors"
	"fmt"
)

type Bitcoin int

func (b Bitcoin) String() string {
	return fmt.Sprintf("%d BTC", b)
}

type Wallet struct {
	// Deposit float64
	balance Bitcoin
}

func (w *Wallet) Deposit(i Bitcoin) {
	w.balance += i
}

func (w *Wallet) Balance() Bitcoin {
	return w.balance
}

func (w *Wallet) Withdraw(bitcoin Bitcoin) error {
	if bitcoin > w.balance {
		return errors.New("on no")
	}

	w.balance -= bitcoin
	return nil
}

func zeroval(ival int) {
	ival = 0
}
func zeroptr(iptr *int) {
	*iptr = 0
}

func Swap(a, b *int) {
	b, a = a, b
}
func SwapP(a, b *int) {
	*b, *a = *a, *b
}
